public class ThreadDemo12 {
    public static void main(String[] args) {
        Thread t1=new Thread() {
            @Override
            public void run() {
                int count=0;
                while (count<5) {
                    count++;
                    System.out.println("线程运行中。。");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("线程结束");
            }
        };
        t1.start();

        try {
            Thread.sleep(7000);
            //join() 就会开始阻塞等待，直至 t1运行结束
            System.out.println("join 开始执行");
            t1.join();
            System.out.println("join 执行结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }
}
